 <?php

require_once  __DIR__ . '/includes/authenticate.php';
include_once __DIR__ . '/db_bb_connect.php';

?>

<h2>Team Info</h2>

<div class='container-fluid'>

<div class='row'>
<div class='col-md-2'></div>
<div class='col-md-8'>

<form method="post" action=""> 

 <select name="season" class="form-control">
         <option id="selected-season" value="" disabled="disabled" selected="selected">Select a season</option>

<?php

	$sql = "SELECT DISTINCT season FROM teams ORDER BY season";
	
	if ($result = $db->query($sql)) {  
  	} else {
      echo "Error: " . $sql . "<br>" . $db->error;
  	}	
	
	while ($row = $result->fetch_assoc()) {
			$season = $row['season'];
			echo "<option value='$season'>$season</option>";
		}
		
?>

</select>

</form>
<br>


<div id="teaminfocontent"> </div>


</div>
<div class='col-md-2'></div>
</div>
</div>

<script type="text/javascript">
 
$( "select" ).on( "change", function( event ) {
  postData = $( this ).serialize();
  callTeamInfoPage(postData);
  event.preventDefault();
});

function callTeamInfoPage(e, postData){
  $.ajax({
  type: "POST",
  url: "./teaminfo_loader.php",
  data: this.postData,
  success: function(data) {
  $("#teaminfocontent").html(data);
  }
  }); 

  e.preventDefault();
};


</script>




